//
//  ChatTitleBean.swift
//  列表标题
//
//  Created by 小柠檬🍋 on 2025/9/7.
//

import Foundation

struct ChatRecordBean : Identifiable {
    let id = UUID()
    var role: AiRoleBean
    var chat: ChatBean? = nil
    var aiRoleOften: String? = nil
    
    
    func getContentStr() -> String {
        var text = chat?.content ??  "暂无消息"
        if text.isEmpty {
            text = "暂无消息"
        }
        let contentType = chat?.contentType
        switch (contentType) {
        case IChatContentType.TYPE_PICTURE.rawValue :
            text = "[图片]"
            break
        case IChatContentType.TYPE_EMOJI_PICTURE.rawValue : 
            text = "[表情]"
            break
        case IChatContentType.TYPE_CONTENT.rawValue :
            break
        case IChatContentType.TYPE_VOICE_MESSAGE.rawValue:
            text = "[语音]"
            break
        case IChatContentType.TYPE_ACTION.rawValue: 
            text = chat?.getPatStr() ?? "暂无消息"
            break
        case .none:
            if text.isEmpty {
                text = "暂无消息"
            }
            return text
        case .some(_):
            if text.isEmpty {
                text = "暂无消息"
            }
            return text
        }
        return text
    }
    
    func read() -> Bool {
        return chat?.read ?? true
    }
}

